window.addEvent('load', function(){
	addswitchbadge.delay(100);
});

function addswitchbadge() {
	var url = location.href;
	//detect 1.5 / 1.6
	var msg = '';
	var link = '';
	var cls = '';
	var thisurl = siteurl.replace (/(http:\/\/[^\/]*)/,'');
	if (url.test(/joomla16-/)) {
		cls = 'joomla15';
		msg = 'Switch to Joomla 1.5';
		link = '../../templates.joomlart.com/'+thisurl;
	} else {
		cls = 'joomla16';
		msg = 'Switch to Joomla 1.6';
		link = '../../joomla16-templates.joomlart.com/'+thisurl;
	}
	
	var div = new Element ('div', {'id':'ja-switch','class':cls}).inject(document.body);
	div.innerHTML = '<a title="'+msg+'" href="'+link+'">'+msg+'</a>';
}